package com.example.saiweisi.controller.systemAdminController;

import com.example.saiweisi.common.Result;
import com.example.saiweisi.controller.request.ReceptionAdminRequest;
import com.example.saiweisi.model.ReceptionAdmin;
import com.example.saiweisi.service.interf.IReceptionAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/receptionadmin")
@RestController
@CrossOrigin
@Slf4j
public class ReceptionAdminController {
    @Autowired
    private IReceptionAdminService receptionAdminService;
    //分页查询
    @GetMapping("/page")
    public Result page(ReceptionAdminRequest receptionAdminRequest) {
        return Result.success(receptionAdminService.page(receptionAdminRequest));
    }
    //添加
    @PostMapping("/add")
    public Result addreceptionadmin(@RequestBody ReceptionAdmin receptionAdmin){
        receptionAdminService.addreceptionadmin(receptionAdmin);
        return Result.success();
    }
    //删除
    @DeleteMapping("/delete{receptionAdminId}")
    public Result deletereceptionadmin(@PathVariable Integer receptionAdminId){
        System.out.println(receptionAdminId);
        receptionAdminService.deletereceptionadmin(receptionAdminId);
        return Result.success();
    }
    //重置密码
    @PutMapping("/resetpassword{receptionAdminId}")
    public Result resetpassword(@PathVariable Integer receptionAdminId){
        receptionAdminService.resetPassword(receptionAdminId);
        return Result.success();
    }
    //批量删除
    @PostMapping("/deletes")
    public Result deletesreceptionadmin(@RequestBody List<Integer> receptionAdminIds){
        receptionAdminService.deletesreceptionadmin(receptionAdminIds);
        return Result.success();
    }
    //根据id查找
    @GetMapping("/{receptionAdminId}")
    public Result getById(@PathVariable Integer receptionAdminId){
        ReceptionAdmin receptionAdmin=receptionAdminService.getById(receptionAdminId);
        return Result.success(receptionAdmin);
    }
    //修改
    @PutMapping("/update")
    public Result updatereceptionadmin(@RequestBody ReceptionAdmin receptionAdmin){
        receptionAdminService.updatereceptionadmin(receptionAdmin);
        return Result.success();
    }
}
